package com.haskie.api.base;

public class RespData<T> {

    private String code = "200";
    private String message = "成功";
    private T data;

    public static <T> RespData<T> ok(T data) {
        return new RespData<T>(data);
    }
    
    public static <T> RespData<T> ok() {
    	return new RespData<>();
    }

    public static <T> RespData<T> fail() {
        return fail(RespCode.INTERNAL_SERVER_ERROR.getCode(),null);
    }

    public static <T> RespData<T> fail(String message) {
        return fail(RespCode.INTERNAL_SERVER_ERROR.getCode(),message);
    }

    public static <T> RespData<T> fail(String code, String message) {
        return new RespData<>(code,message);
    }

    public static <T> RespData<T> fail(String code, String message, T data) {
        return new RespData<T>(code,message,data);
    }

    public static <T> RespData<T> failByParam(String message) {
        return fail(RespCode.INTERNAL_SERVER_ERROR.getCode(),message);
    }

    public RespData(T data) {
        super();
        this.data = data;
    }
    
    public RespData(String message) {
        super();
        this.message = message;
    }

    public RespData(String code, String message) {
        super();
        this.message = message;
        this.code = code;
    }

    public RespData(String code, String message, T data) {
        super();
        this.message = message;
        this.code = code;
        this.data = data;
    }

    public RespData() {
        super();
    }

    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public T getData() {
        return data;
    }
    public void setData(T data) {
        this.data = data;
    }

}